package com.czxy.demo01;

/**
 * Created by hp on 2020/1/31.
 */
public class Test12 {
    public static void main(String[] args) {
        String[][] all = {
                {"张三","37","89","5"},
                {"李四","95","41","79"},
                {"王五","60","84","29"},
                {"赵六","87","46","86"}
        };
        printMathScore(all);
        getCountMathScore(all);
        getAvgMathScore(all);
        getAvgName(all);
        getAvgCount(all);
    }
    public static void printMathScore(String[][] arr){
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i][0]+"数学成绩"+arr[i][2]);
        }
    }
    public static void getCountMathScore(String[][] arr){
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum+=Integer.parseInt(arr[i][2]);
        }
        System.out.println("数学总分"+sum);
    }
    public static void getAvgMathScore(String[][] arr){
        int sum = 0;
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            sum+=Integer.parseInt(arr[i][2]);
            count++;
        }
        System.out.println("数学平均分"+sum/count);
    }
    public static void getAvgName(String[][] arr){
        int sum = 0;
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            sum+=Integer.parseInt(arr[i][2]);
            count++;
        }
        int i = sum/count;
        System.out.println("数学成绩高于平均分的人");
        for (int j = 0; j < arr.length; j++) {
            if (i>Integer.parseInt(arr[j][2])){
                System.out.println(arr[j][0]);
            }
        }
    }
    public static void getAvgCount(String[][] arr){
        int sum = 0;
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            sum+=Integer.parseInt(arr[i][2]);
            count++;
        }
        int i = sum/count;
        int a = 0;
        System.out.println("数学成绩高于平均分的人");
        for (int j = 0; j < arr.length; j++) {
            if (i>Integer.parseInt(arr[j][2])){
                a++;
            }
        }
        System.out.println("数学成绩关于平均分的人数"+a+"人");
    }
}
